home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / clipper / nannws31.zip / MULTISEL.PRG < prev    next >
Text File  |  1988-08-09  |  4KB  |  111 lines

  1. *  Program: MultiSel.prg       (Multiple Select)
  2. *  Author:  David R. Alison
  3. *  Version: Clipper Summer '87
  4. *  Notes:   Example of multiple choice selection
  5. *           with ACHOICE().
  6. *  Public Domain Software.
  7.  
  8. PUBLIC mre, mel
  9.  
  10. **  Here we declare our array of menu choices...
  11. DECLARE reports[10]
  12. reports[1] = 'Customer Master List            '
  13. reports[2] = 'Customer Mailing List           '
  14. reports[3] = 'Parts List by Part Number       '
  15. reports[4] = 'Parts List by Name              '
  16. reports[5] = 'Parts List by Machine           '
  17. reports[6] = 'Machine Failure Analysis        '
  18. reports[7] = 'Average Parts Cost per Machine  '
  19. reports[8] = 'Average Labor Cost per Machine  '
  20. reports[9] = 'Current Inventory Status        '
  21. reports[10]= 'Current Machine MTBF            '
  22.  
  23. **  Create the screen for menu selection
  24. CLEAR
  25. frame = '╔═╗║╝═╚║'
  26. @ 4, 23, 15, 58 BOX frame
  27. @ 16, 23, 20, 58 BOX frame
  28. @ 17, 26 SAY 'Press Enter to check off each'
  29. @ 18, 26 SAY 'report to print.  F5 tags all,'
  30. @ 19, 26 SAY 'F6 untags all.  Esc exits...'
  31.  
  32. **  mel & mre are public memvars that are modified 
  33. **  by the ACHOICE UDF "getfield."  A UDF is used
  34. **  because we are only going to flag the field
  35. **  with a check mark.  This way the user can select
  36. **  several fields.  The enter key acts as a toggle
  37. **  for the flag.  If a flag is already there, it
  38. **  removes it and vice versa.
  39. mel = 1         && Initial choice element
  40. mre = 1         && Initial relative window row
  41. choice = 0      && Menu choice
  42.  
  43. **  Here is the meat of the program.  We will loop
  44. **  through the ACHOICE() function until the user
  45. **  presses Enter.  Then we will call the UDF "getfield"
  46. **  which merely changes the public memvars mel and 
  47. **  mre to reflect the position of the cursor within 
  48. **  ACHOICE.
  49. DO WHILE 1 = 1
  50.    choice = ACHOICE(5, 25, 14, 57, reports, .t., ;
  51.             "getfield", mel, mre)
  52.    DO CASE
  53.         
  54.       **  Checks to see if the last key the user
  55.       **  selected was the enter key.  If so, modify
  56.       **  the reports array element to either add or
  57.       **  remove the check mark.  Then loop back
  58.       **  through the DO WHILE loop and call another
  59.       **  ACHOICE.
  60.       CASE lastkey() = 13
  61.       IF substr(reports[choice],32,1) = chr(251)
  62.          reports[choice] = substr(reports[choice],1,31)+' '
  63.       ELSE
  64.          reports[choice] = substr(reports[choice],1,31)+chr(251)
  65.       ENDIF
  66.  
  67.       **  If the last key pressed was the F5 key,
  68.       **  tag all of the items, regardless of current
  69.       **  status
  70.       CASE lastkey() = -4
  71.       FOR i = 1 TO 10
  72.          reports[i] = substr(reports[i],1,31)+chr(251)
  73.       NEXT
  74.  
  75.       **  If the last key pressed was the F6 key,
  76.       **  untag all of the items, regardless of current
  77.       **  status
  78.       CASE lastkey() = -5
  79.       FOR i = 1 TO 10
  80.          reports[i] = substr(reports[i],1,31)+' '
  81.       NEXT
  82.  
  83.       **  If the last key pressed was the Esc key,
  84.       **  exit the loop.
  85.       CASE lastkey() = 27
  86.       EXIT
  87.  
  88.    ENDCASE
  89. ENDDO
  90.  
  91. CLEAR
  92.  
  93. **  Determine which reports were selected and generate them.
  94. FOR i = 1 TO 10
  95.    IF substr(reports[i],32,1) = chr(251)  && Is there a check?
  96.       reports[i] = trim(substr(reports[i],1,31))
  97.       ? 'Printing the "'+ reports[i] + '" report.'
  98.    ENDIF
  99. NEXT
  100.  
  101. FUNCTION getfield
  102. **  Function for use with ACHOICE().  Returning
  103. **  the 1 tells ACHOICE() to continue with the
  104. **  selection process.
  105. PARAMETERS mode, element, relative
  106. mel = element
  107. mre = relative
  108. RETURN(1)
  109.  
  110. * EOP: MULTISEL.PRG
  111.